/*
 *  Copyright 2016 Google Inc. All Rights Reserved.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.google.android.apps.forscience.whistlepunk.metadata;

import androidx.annotation.NonNull;
import com.google.android.apps.forscience.whistlepunk.devicemanager.ConnectableSensor;
import java.util.List;
import java.util.Objects;
import java.util.Set;

/**
 * The sensors that should be available in an experiment are defined as:
 *
 * <p>- The built in sensors - plus (set union) getIncludedSensors - minus (set difference)
 * getExcludedSensorIds
 *
 * <p>For simplicity of database migration, there may be built-in sensors included in
 * getIncludedSensors, and non-built-in sensors included in getExcludedSensors.
 */
public class ExperimentSensors {
  private List<ConnectableSensor> externalSensors;
  private Set<String> excludedInternalSensorIds;

  public ExperimentSensors(
      List<ConnectableSensor> externalSensors, Set<String> excludedInternalSensorIds) {
    this.externalSensors = externalSensors;
    this.excludedInternalSensorIds = excludedInternalSensorIds;
  }

  public List<ConnectableSensor> getExternalSensors() {
    return externalSensors;
  }

  public Set<String> getExcludedInternalSensorIds() {
    return excludedInternalSensorIds;
  }

  @NonNull
  @Override
  public String toString() {
    return "ExperimentSensors{"
        + "externalSensors="
        + externalSensors
        + ", excludedInternalSensorIds="
        + excludedInternalSensorIds
        + '}';
  }

  // Auto-generated by Android Studio

  /** For testing only */
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    ExperimentSensors that = (ExperimentSensors) o;

    return Objects.equals(externalSensors, that.externalSensors)
        && Objects.equals(excludedInternalSensorIds, that.excludedInternalSensorIds);
  }

  /** For testing only */
  @Override
  public int hashCode() {
    return Objects.hash(externalSensors, excludedInternalSensorIds);
  }
}
